package com.sinoglobal.ningxia.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sinoglobal.ningxia.R;
import com.sinoglobal.ningxia.beans.programInfoVo;

/**
 * @author qiwx
 * @createdate 2014-6-26 下午3:32:39
 * @Description: 节目剧集
 */
public class ProgramHistoryAdapter extends BaseAdapter {

	List<programInfoVo> data=new ArrayList<programInfoVo>();
	LayoutInflater mInflater;

	public ProgramHistoryAdapter(Context context, List<programInfoVo> data) {
		this.data = data;
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewholder;
		if (convertView == null) {
			viewholder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.program_history_listview_item, null);
			viewholder.setDate((TextView) convertView.findViewById(R.id.program_history_date));
			viewholder.setTitle((TextView) convertView.findViewById(R.id.program_history_title));

			convertView.setTag(viewholder);
		} else {
			viewholder = (ViewHolder) convertView.getTag();
		}
		programInfoVo bean = data.get(position);
		viewholder.getDate().setText(bean.getPeriod());
		viewholder.getTitle().setText(bean.getName());
		return convertView;
	}

	class ViewHolder {
		// 栏目期数与时间
		TextView date;
		// 节目
		TextView Title;

		public TextView getDate() {
			return date;
		}

		public void setDate(TextView date) {
			this.date = date;
		}

		public TextView getTitle() {
			return Title;
		}

		public void setTitle(TextView title) {
			Title = title;
		}

	}

}
